﻿using CodeFirstMVC3.DataAccess.Model;
using CodeFirstMVC3.DataAccess.Repository;
using CodeFirstMVC3.Domain.DataAccess;
using CodeFirstMVC3.Domain.Service;
using CodeFirstMVC3.Service;
using StructureMap;

namespace CodeFirstMVC3.Web.Infrastructure
{
    public static class IoC
    {
        public static IContainer Initialize()
        {
            ObjectFactory.Initialize(x =>
            {
                x.Scan(scan =>
                {
                    scan.TheCallingAssembly();
                    scan.WithDefaultConventions();
                    //scan.Assembly("Paradizon.Service");
                });
                x.For<IDbContext>().Use<CodeFirstDbContext>();
                x.For(typeof(IRepository<>)).Use(typeof(Repository<>));
                x.For<IMemberProvider>().Use<MemberProvider>();
                x.For<IMemberService>().Use<MemberService>();
                x.For<IUserService>().Use<UserService>();
                x.For<IRoleService>().Use<RoleService>();
                x.For<IJobService>().Use<JobService>();
            });
            return ObjectFactory.Container;
        }
    }

}